package com.huaxin.hxmoduleworkorder.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.huaxin.hxmoduleworkorder.common.enums.base.BaseCodeEnum;

public enum MaintenanceOrderElectricianTaskOperation implements BaseCodeEnum {
    EDIT("edit", "编辑"),
    ASSIGN("assign", "分配"),
    ACCEPT("accept", "接单"),
    REJECT("reject", "拒单"),
    ON_SITE("on_site", "标记到场"),
    START_PROCESS("start_process", "开始处理"),
    RESOLVE("resolve", "提交解决"),
    CANCEL("cancel", "取消"),     //任务不可取消，工单取消时任务取消
    VIEW("view", "查看");

    @EnumValue
    private final String code;
    private final String displayName;

    MaintenanceOrderElectricianTaskOperation(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }

    @JsonValue
    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDisplayName() {
        return displayName;
    }

    public static MaintenanceOrderElectricianTaskOperation of(String code) {
        for (MaintenanceOrderElectricianTaskOperation op : values()) {
            if (op.code.equalsIgnoreCase(code)) {
                return op;
            }
        }
        return null;
    }

    /**
     * 判断是否为有效状态
     */
    public static boolean isValid(String code) {
        return of(code) != null;
    }
}